#ifndef B_PHYSICS_MOTIONSTATE_H_
#define B_PHYSICS_MOTIONSTATE_H_

#include <LinearMath/btMotionState.h>

/* Using one of these to render the physics based objects allows
   bullet to interpolate data over several frames, acting as a 
   massive optimisation
*/
class BPhysicsMotionState :  public btMotionState
{
private:
    btTransform m_graphicsWorldTrans;
    btVector3   m_graphicsScale;
    
public:
    BPhysicsMotionState( const btTransform& world, const btVector3& graphicsScale)
        : m_graphicsScale(graphicsScale),
          m_graphicsWorldTrans(world)
    {
    }

    ///synchronizes world transform from user to physics
    virtual void	getWorldTransform(btTransform& centerOfMassWorldTrans ) const 
    {
        centerOfMassWorldTrans = 	m_graphicsWorldTrans;
    }

    ///synchronizes world transform from physics to user
    ///Bullet only calls the update of worldtransform for active objects
    virtual void	setWorldTransform(const btTransform& centerOfMassWorldTrans)
    {
        m_graphicsWorldTrans = centerOfMassWorldTrans;
    }
    const btVector3& GetGraphicsScale() const { return m_graphicsScale; }
    void SetGraphicsScale(const btVector3& val) { m_graphicsScale = val; }
};


#endif